package com.liuyang.demo.time;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 版权信息: © 聚均科技
 *
 * @author Liu
 * @description
 * @since 2023/2/16 21:55
 */
public class DateUtil2 {

    /**
     * 不含当前月的前12个月，格式yyyy-M
     * @return
     */
    public static List<String> beforeTwentyMonthsExcludeCurrent(){
        List<String> list = new ArrayList<>();
        LocalDate current = LocalDate.now();
        for(int i=-12;i<0;i++){
            LocalDate date = current.plusMonths(i);
            String s = DateTimeFormatter.ofPattern("yyyy-M").format(date);
            list.add(s);
        }
        return list;
    }

}
